#include "../../common/rabbitmq.hpp"

#include <gflags/gflags.h>
DEFINE_string(user,"root","rabbitmq用户名");
DEFINE_string(password,"123456","rabbitmq密码");
DEFINE_string(host,"127.0.0.1:5672","rabbitmq服务器地址信息 host:port");


DEFINE_bool(run_mode, false, "程序运行模式:true为发布模式,false为调试模式");
DEFINE_string(log_file, "", "发布模式中,用于存放日志的文件路径");
DEFINE_int32(log_level, 0, "发布模式中,日志输出等级");
void callback(const char *message,size_t len)
{
    LOG_INFO("收到消息:{}",std::string(message,len));
    std::string msg;
    msg.assign(message,len);
    std::cout<<msg<<std::endl;
}
int main(int argc, char *argv[])
{
    google::ParseCommandLineFlags(&argc, &argv, true);
    init_logger(FLAGS_run_mode, FLAGS_log_file, FLAGS_log_level);
    MQClient client(FLAGS_user,FLAGS_password,FLAGS_host);
    client.declareComponents("test-exchange","test_queue");
    client.consume("test_queue",callback);

    std::this_thread::sleep_for(std::chrono::seconds(60));
    return 0;
}